Improve Fleet-Ops server test coverage - #277
Conversation
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
Adds server/tests/Feature/Http/Api/DriverControllerOrganizationsTest.php covering currentOrganization with the company-session fallback chain and the unresolvable-company error branch, and listOrganizations returning every company the driver's user account belongs to through company_users. Adds server/tests/Feature/Http/Api/DriverControllerSessionHelpersTest.php covering the protected session/persistence helpers: session and current company resolution, the company-from-request seam, user info application, user/driver/device persistence with firstOrCreate dedupe, uuid and point utilities, null file resolution, driver lookup with resource wrapping, and the queryWithRequest vendor filter pipeline (whose query param is matched against vendors.public_id by the controller callback and drivers.vendor_uuid by DriverFilter). The switchOrganization endpoint remains structurally blocked: loading the core SwitchOrganizationRequest fatals against the harness FormRequest authorize() signature. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Adds server/tests/Feature/Http/Api/PurchaseRateControllerOrderCreationTest.php covering createOrderFromServiceQuote against SQLite: the default-type order path, payload construction from preliminary data with pickup, dropoff, and return places persisted, adoption of the quote's payload and service-rate type, and the integrated-vendor failure branch returning an api error response with no order written. Exercising this surface uncovered two latent bugs, both fixed: - The preliminary-data block called setDropoff($return) instead of setReturn($return), which fatals with a TypeError for quotes without a return place (the common case) and silently overwrote the dropoff with the return place otherwise. The return place is now assigned through setReturn and only when present. - The integrated-vendor catch branch returns response()->apiError(...) from a method declared to return ?Order, fataling with a TypeError on every vendor failure. The declaration is now Order|JsonResponse|null, matching the existing caller which already type-checks the result. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Adds server/tests/Feature/Http/Internal/LiveControllerEndpointsTest.php covering the LiveController map feeds against SQLite with a tagged-cache fake: active-order destination coordinates (hydrating real Point instances from packed WKB so getCurrentDestinationLocation's lat/lng filter executes), active routes with the nested driver/tracking/payload constraints and the unassigned-driver drop, the live order query with exclusion filtering, viewport-bounded driver and vehicle listings with the spatial location guards, and filtered place listings. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Adds server/tests/Feature/Http/Internal/SearchControllerEndpointTest.php covering the internal global search endpoint against SQLite with an admin session user bypassing per-type permission checks: the blank-query short circuit, requested-type parsing, order search through the tracking-number relation subquery, driver search through the user relation, the generic column search used by vehicles and fleets with limits, and the unmatched-query empty result. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Adds server/tests/Unit/Support/ResolvesOrderServiceStopsDbTest.php covering the ResolvesOrderServiceStops helpers the fake-based trait test cannot reach, against SQLite: proof resolution by instance/public-id with invalid-input rejection, endpoint stop completion via stored tracking statuses, next-incomplete-stop advancement persisting the payload's current destination, current-stop activity detection through tracking status codes for both endpoint and waypoint stops, endpoint tracking-number creation with barcode fakes and payload linkage, endpoint activity insertion writing tracking statuses and relinking the number, tracking-number status lookups preferring the linked status uuid, and updateCurrentServiceStopActivity's location guard, endpoint-insertion, and skip branches. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Adds four categorized tests covering small remaining surfaces against SQLite: - server/tests/Unit/Observers/FleetOpsCompanyUserAndServiceAreaObserversTest.php: CompanyUserObserver driver deletion on membership removal and status syncing driven by wasChanged, and ServiceAreaObserver zone cascade deletion with the country-border polygon helper seam. - server/tests/Unit/Listeners/HandleOrderDispatchFailedListenerTest.php: the order-creator lookup and failure notification hand-off through a notification dispatcher fake, plus the missing-creator skip. - server/tests/Unit/Console/AssignDriverRolesCommandTest.php: company traversal with the users.driver expansion, the admin skip, the role-assignment error branch, and the empty-company quiet run. - server/tests/Unit/Support/AiCapabilityPermissionsTest.php: the shared AbstractFleetOpsAICapability helpers through OperationalQueryCapability — admin permission bypass, gate delegation seam, search-term extraction with stop-word filtering, and the multi-column like matcher. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Adds server/tests/Unit/Models/SensorReadingsTest.php covering the Sensor model reading pipeline against SQLite with the token-guard auth manager and disabled activity log: out-of-threshold readings opening a single threshold alert without duplication, normal readings resolving open alerts, severity mapping and alert message generation, and subject position creation from latitude/longitude and location-keyed attributes. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Adds server/tests/Feature/Http/Internal/VendorControllerEndpointsTest.php covering the internal VendorController against SQLite with an excel fake: the export download with filename/format handling, the distinct status listing, the import pipeline with resolved files and the invalid-file error branch, the vendor/driver/contact lookup helpers including trashed and or-fail variants, the contact resource payload projection, and the vendor personnel updateOrCreate/list/create/delete helpers. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Adds server/tests/Feature/Http/Internal/ContactControllerEndpointsTest.php covering the internal ContactController against SQLite with an excel fake: export downloads, the import pipeline with the invalid-file error branch, contact lookup and vendor-conversion helpers (creation, personnel linkage, transaction wrapper, vendor resource payload), the customer context migration rewriting orders and customer-portal issue metadata onto the converted vendor, and the customer portal welcome-email guard branches with extension detection. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Adds server/tests/Unit/Support/OperationalQueryDistributionTest.php covering the OperationalQueryCapability driver geofence distribution against SQLite with spatial containment stand-ins: the empty-fleet short circuit, online and updated_at filter application, packed-WKB point hydration, and per-service-area/zone containment counting as an admin session user. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Adds server/tests/Unit/Notifications/OrderFailedChannelsTest.php covering the OrderFailed notification title construction with the waypoint-tracking-number preference, broadcast channel construction across company/api/order channels, and the fcm/apn delegation seams. Adds server/tests/Unit/Console/AssignCustomerRolesCommandTest.php covering the fleetops:assign-customer-roles command traversal with user resolution, the role-assignment error branch, and the quiet empty run. Adds server/tests/Unit/Models/IntegratedVendorLifecycleTest.php covering the IntegratedVendor created/updated/deleted boot hooks resolving the lalamove provider, credential access, the provider/api bridges, and the webhook-url mutator's explicit and derived-default branches. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Adds server/tests/Unit/Http/Resources/MaintenanceResourcesTest.php covering both maintenance API resources: the Ember maintenance-subject and facilitator type injections with empty passthroughs, the morph transformer null and JsonResource fallbacks, and full serialization of loaded polymorphic subject/maintainable relations through the whenLoaded callbacks against SQLite. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Adds server/tests/Feature/Http/Api/OrderControllerStartActivityTest.php covering the API OrderController startOrder and updateActivity endpoints against SQLite with a real transport order-config flow: the unknown-order, already-started, missing-driver, adhoc-without-driver, and not-dispatched error branches; the skip-dispatch success path that starts the order, assigns the driver's current job, fires OrderStarted, and delegates into updateActivity with the started activity; and the updateActivity unknown/completed rejections plus the dispatched-activity branch firing OrderDispatchFailed when no driver is assigned. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Adds server/tests/Feature/Http/Api/OrderControllerLifecycleActionsTest.php covering the API OrderController lifecycle endpoints against SQLite with the transport order-config flow: getNextActivity resolving flow steps with the 404 branch and proof-of-delivery flag/method injection on completing activities, completeOrder's incomplete-waypoint guard, cancelOrder transitioning the order to canceled, and setDestination's validation and current-service-stop persistence. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Adds server/tests/Feature/Http/Api/OrderControllerPersistenceHelpersTest.php covering the API OrderController protected persistence helpers against SQLite: customer contact firstOrCreate dedupe, the company timezone fallback, order/proof/file creation, the finalize-order job dispatch through the chainable dispatch shim, the routing-engine delegation seam, storage writes via a filesystem fake, proof subject scoping for order and entity subjects, entity editing settings lookup, and the order/proof/comment resource wrappers. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Adds server/tests/Feature/Http/Internal/OrderControllerActivityFlowsTest.php covering the internal OrderController against SQLite with the transport order-config flow: start's unknown/already-started/driverless guards and the success path assigning the driver's current job and firing OrderStarted, updateActivity's proof-of-delivery requirement with the bypass flag, the dispatched-activity failure without an assigned driver, lifecycle activity updates writing tracking statuses, next-activity flow resolution, and setDestination's single-stop rejection plus multi-waypoint validation and persistence. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Adds server/tests/Unit/Support/FuelEfficiencyAndCanceledHandlersTest.php covering the FuelEfficiency weekly cost-per-distance aggregation with a YEARWEEK SQLite stand-in and the empty-series fallback, the HandleOrderCanceled listener's driver lookup and notification helpers through a dispatcher fake with the unassigned fallback, and the OrderCompleted notification broadcast channels plus fcm/apn delegation seams. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Adds server/tests/Unit/Models/ServiceAreaGeometryTest.php covering the ServiceArea geometry helpers: circular multi-polygon creation from a point with ring closure, polygon extraction from the border with geotools point-in-polygon containment for single and multiple coordinates, and the centroid/location accessor seam that requires the GEOS engine. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Adds server/tests/Feature/Http/Internal/ServiceQuoteControllerQueryRecordTest.php covering queryRecord against SQLite with the calculate distance-matrix provider: quoting a stored payload against a specific service rate with single-quote selection, quoting all servicable company rates with best-quote picking, the integrated-vendor resolution seam, and the preliminary fallback for unknown payloads. Exercising queryRecord surfaced a latent fatal, now fixed: the endpoint called getAllStops()->mapInto(Place::class), but getAllStops() already normalizes every stop into a Place instance — re-wrapping passed Place models into the model constructor and threw a TypeError for every real payload quote. The stops collection is now used directly. Seventh production bug found and fixed by this campaign. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Adds server/tests/Unit/Models/DriverModelHelpersTest.php covering the Driver model helpers against SQLite: position creation from latitude/longitude and location-keyed coordinate variants with subject scoping, user resolution through the relation with the uuid fallback, driver creation from import rows exercising both the existing-user lookup and fresh-user provisioning branches with vehicle resolution and country normalization, and identifier lookups matching user name/email and driver license/public-id columns. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Adds server/tests/Feature/Http/Internal/OrchestrationControllerImportOrdersTest.php covering the internal OrchestrationController importOrders endpoint against SQLite: the empty-rows 422 rejection; a full pickup/dropoff row import resolving the order config, creating customer contacts and facilitator vendors on demand, matching vehicles by plate and drivers by identifier, persisting pickup/dropoff places with locations, required skills, and entities; multi-waypoint groups collapsing into a single order with one waypoint per row; and per-group failure capture with transaction rollback on invalid dates. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Adds server/tests/Unit/Models/SmallModelSurfacesTest.php covering small remaining surfaces against SQLite: Zone creation with the active-status default and its relations/polygon construction with the GEOS centroid seam, PurchaseRate relations plus resolveFromRequest by uuid and public id, the Customer creating hook forcing the customer type, ContactObserver email/phone availability checks with the user deletion path, and the CreateTrackingStatusRequest session authorization plus its duplicate-status validation closure across matched, unmatched, and bypassed inputs. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Adds server/tests/Unit/Support/TelematicServiceTest.php covering the TelematicService against SQLite: device linking with provider-identity validation, telemetry reconciliation, and dedupe on re-link; device event storage with full telemetry field mapping, location normalization, and payload-resolved device attachment; sensor storage with identity validation, default locations, and device-linked identity fallback; device filtering by status and search; connection test recording across success and failure; credential decryption fallbacks for plain json and empty values through an encrypter fake; and webhook telematic resolution by integration id, provider account metadata, and device identity. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Adds server/tests/Feature/Http/Internal/PositionControllerReplayMetricsTest.php covering the internal PositionController replay endpoint (channel and position-id guards, missing-position rejection, and the replay job dispatch with speed handling), the metrics endpoint with input guards and calculation over stored positions with packed-WKB coordinates, and the API ContactController protected helpers: create/update input normalization with phone formatting and type defaults, contact instantiation and upsert persistence, public-id lookup, place uuid and related-user resolution, resource wrappers, and json/error responses. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Adds server/tests/Unit/Support/MaintainableAndOperationalAlertsTest.php covering the Maintainable trait through the Part model against SQLite: needsMaintenance across no-history, overdue-scheduled, and interval-configured paths, maintenance scheduling with priority details, and cost/frequency aggregation over completed history. Also covers the ProcessOperationalAlerts helper bodies: the operational orders query window with status/company filters, latest-position lookup, alert settings resolution with defaults, route point collection with pair normalization and axis-swap handling, minimum distance measurement, and the once-only notification metadata guard. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Adds server/tests/Feature/Http/Internal/WorkOrderAndConfigSurfacesTest.php covering the internal WorkOrderController sendEmail flow (missing assignee and missing email 422 guards, and the success path sending the dispatch mail through a mailer fake with activity logging disabled), the excel export/import delegation helpers, the OrderConfigController delete flow with the core-service guard and soft deletion, and the SensorFilter public-relation resolution with company scoping against SQLite. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Adds server/tests/Unit/Models/OrderPurchaseAndDriversTest.php covering the Order purchase helpers against SQLite: service quote resolution by uuid and public id with purchase-rate creation, the unresolvable-quote failure, the no-quote fallback creating an internal dispatch transaction, purchase-rate attachment relinking the new transaction to the order and voiding the superseded one, and closest-driver discovery through the spatial company/user/driver chain with the located-pickup requirement. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Adds server/tests/Unit/Support/OrchestrationPayloadBuilderTest.php covering the OrchestrationPayloadBuilder computation helpers: payload demand aggregation across entities with gram/pound weight conversion and centimetre dimension normalization into litres, the order-meta fallback for entity-less payloads, vehicle-only VROOM entries with location requirements, capacity arrays, and max-task handling, safe meta access swallowing accessor failures, and coordinate validation with place-location resolution. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Adds server/tests/Feature/Http/Api/DeviceControllerCrudTest.php covering the API DeviceController against SQLite: find/delete with not-found handling and soft deletion, detach with the missing-device 404 and the failure branch logging, device creation/update persistence helpers with resource wrappers, input mapping building last-position points from latitude/longitude, blank-attachable clearing, and the attachment failure logging helpers. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Second defect found during coverage work —
|
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Place::insertFromMixed() called insertFromGeocodingLookup() for any plain address string, but no such method existed on Place or any ancestor, so the call always raised BadMethodCallException. Define it as the insert-side twin of createFromGeocodingLookup, mirroring insertFromGoogleAddress. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
The Rule stand-in accepted where() closures and discarded them, so the company/soft-delete scoping inside them never executed. Run them against a recording double instead and assert the recorded constraints. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…y fallback Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Summary
This is a progressive backend-only coverage PR for Fleet-Ops
./server.server/tests/Unit/...andserver/tests/Feature/...instead of adding more flat root-level coverage files.response()->apiError(...)) and job dispatch branches (Job::dispatch/dispatchIf) are reachable under test — previously these fatally errored and structurally blocked coverage on nearly every controller.Latest Local Coverage
Fresh host run from
COMPOSER_PROCESS_TIMEOUT=0 composer coverage:baseline:Coverage gate verification:
php scripts/coverage-summary.php coverage/clover.xml --fail-under=100correctly fails while coverage is below 100%.Latest Progress
collection()scoping (17 classes),queryWithRequestacross every API controller (19 classes), importcreateFromImportdelegation (13 classes), filter date ranges, Excel download/import seams, requestauthorize()gates, resource relation resolution, observer/listener query seams, and assorted controller/command/job seams.Place::insertFromMixed()calledinsertFromGeocodingLookup()for any plain address string, but no such method existed onPlaceor any ancestor — every such call raisedBadMethodCallException. Defined it as the insert-side twin ofcreateFromGeocodingLookup, mirroring the existinginsertFromGoogleAddressshape (the already-present but callerlessgetValuesFromGeocodingLookup()is exactly its other half).Place::insertFromCoordinates()guarded empty reverse-geocoding results with!$results->count() === 0, comparing a bool to an int so the guard never fired — with no results the code fell through to an address array carrying location0,0, whicharray_mergelayered over the caller's real coordinates, silently inserting places at Null Island instead of returningfalseas documented.Lalamove::getQuotationForMarket()calledinstance(null, null, $market), putting the market in thebool $sandboxslot — withoutstrict_typesthe string coerced totrue, so market-scoped quotations ran against the sandbox host with the market silently dropped.OrderConfig::default()declared a non-nullableselfreturn while returningfirst(), so companies without a stored transport config fataled instead of having one provisioned.ServiceRatecalledCollection::sortByDesc()with no argument, throwing whenever a parcel outsized every fee tier.queryWithRequestseam on all 19 API controllers, Lalamove response handling (Guzzle client is an injectable property),Support\Auth::can()and the form requests gating on it (a real spatie fixture works), and every GEOS-dependent geometry accessor (inject aBrick\Geo\Engine\GeometryEngineRegistryfake — no native extension needed). Blocked labels are worth re-probing rather than trusting.Validation
Run on the host runtime (asdf PHP 8.4 with Xdebug,
XDEBUG_MODE=coverage), no Docker:php -l <changed test file>php scripts/pest-runner.php <changed test file>— pass count compared against the declaredtest(count, since a fatal truncates a run without reporting any failureXDEBUG_MODE=coverage php scripts/coverage-file-runner.php --coverage-clover=... <changed test file>— per-line slice check that the intended lines actually executed, before trusting a green assertionvendor/bin/php-cs-fixer fix --using-cache=no <changed file>composer test:lintPATH=<asdf php 8.4 bin>:$PATH XDEBUG_MODE=coverage COMPOSER_PROCESS_TIMEOUT=0 composer coverage:baselinephp scripts/coverage-summary.php coverage/clover.xml --fail-under=100git diff --check/git diff --cached --checkCurrent Lowest Coverage Targets
Next backend coverage slices, from the fresh local Clover report (highest absolute uncovered):
server/src/Http/Controllers/Api/v1/OrderController.phpserver/src/Http/Controllers/Internal/v1/OrderController.phpserver/src/Models/Place.phpserver/src/Http/Controllers/Api/v1/DriverController.phpserver/src/Models/Payload.phpThese files are now majority-dead rather than untested: 5 of the 7 remaining in
Models/Place.php, 2 of the 5 inApi/v1/DriverController.php, and 2 of the 5 inModels/Payload.phpare confirmed unreachable (see below).Practical ceiling
A growing share of what remains is provably unreachable rather than untested. Confirmed by direct analysis so far:
Casts/{Point,Polygon,MultiPolygon}instanceof GeometryInterface(orExpression) is tested before each concrete spatial type, so the later arms are shadowedHttp/Resources/v1/{Maintenance,MaintenanceSchedule,WorkOrder,Order}Find::httpResourceForModel()always resolves a class, falling back toFleetbaseResource, so theJsonResourcefallbacks never runModels/Place::createFromMixedisCoordinatesStrict()inside a branch already gated on it one arm aboveModels/Place::findExistingSharedPlace$locationis initialised to aSpatialPointand the catch assigns one, so the non-point guard cannot fireModels/Place::insertFromMixed(address key)is_string($place)branch, andempty()on a non-numeric string offset is always true, so it never firesModels/Place::insertFromMixed(GoogleAddress arm)is_array($place) || is_object($place)arm that catches every object firstHttp/Controllers/Api/v1/OrderController::updateActivityif (!$order)guard follows a try/catch whosefindOrder()is: Order-typed and throws rather than returning nullSupport/Utils::coordsToCircle0..360loop closes the circle exactly, so the closing-point guard never triggersHttp/Controllers/Internal/v1/GeocoderControllergetPointFromCoordinates(), declared: Point(non-nullable)Http/Controllers/Internal/v1/MetricsController$request->date()against not being aDateTime; it returns Carbon, which extends itHttp/Controllers/Api/v1/DriverControllerIntegrations/Lalamove::__callStaticinstanceis a defined public static, so PHP never routes it through__callStaticHttp/Controllers/Internal/v1/OrderController::statusesmethod_exists($config, 'activities'), butOrderConfig::activities()is declaredHttp/Controllers/Internal/v1/TelematicController::testCredentialsregistry->resolve(), typed: TelematicProviderInterface, which throws rather than returning null (the surrounding try/catch reports it)Models/ServiceArea::createMultiPolygonFromPointUtils::coordsToCircle()already returns a closed ring, sofirst !== lastis never trueHttp/Resources/v1/{PurchaseRate,TrackingStatus}relation accessorsmethod_exists($this, 'loadMissing'), but no class in the hierarchy (FleetbaseResource->JsonResource) declares it — it only resolves via__call, whichmethod_existsdoes not seeModels/Payload::setPlacePlace::createFromMixed(): ?Placealways yields a Model or null, so theStr::isUuid()arm and the trailingelseare both shadowed by theinstanceof Modelarm between themModels/ServiceRate::getLngLatFromPlacePlace::getLocationAsPoint(), declared: SpatialPoint(non-nullable), and aSpatialPointalways exposesgetLat/getLngExports/VehicleExport::locationPartUtils::castPoint(), which catches every failure and falls back toPoint(0, 0), so it is never falsyModels/Place::insertFromMixed/createFromMixedThree things previously written off as untestable turned out not to be, and are now covered:
queryWithRequestseam on all 19 API controllers — it needed only a session store, route-resolver stub and a couple of request macros;post/requesthelpers are private, but the Guzzle client is an injectable property, so aMockHandlerexercises the real code path without network access;Support\Auth::can()and the form requests that gate on it — a real spatie fixture works (permissions seeded with guardsanctum, plusmodel_has_permissionsrows keyed to the session user's CompanyUser uuid). The internal create-driver and create-order-config requests now resolve opposite ways through that one gate, which proves the permission is genuinely consulted rather than blanket-true.The lesson is to re-probe "blocked" labels periodically rather than trusting them.
Two further lines (
Internal/v1/OrderController887-888) are reachable only once the upstreamfindByIdOrFaildefect below is fixed, and are deliberately left uncovered rather than shimmed green.A handful more are blocked by genuinely external dependencies — Firebase-backed push payloads, the
Illuminate\Encryption\Encrypter(absent from this vendor tree), and MySQL-onlyst_distance_spherespatial predicates that SQLite cannot evaluate.Known upstream defect (needs a
core-apipatch)Model::findByIdOrFail()infleetbase/core-apithrowsBadMethodCallExceptioninstead of theModelNotFoundExceptionit documents, because it calls agetModelNotFoundException()method that does not exist on Eloquent's Builder. Four call sites in this package havecatch (ModelNotFoundException)blocks that can never fire, so missing records surface as HTTP 500s. Details, affected lines and a suggested fix are in this PR comment. Two lines inInternal/v1/OrderController.phpare intentionally left uncovered pending that fix rather than shimmed green.Known in-package defect (deferred, not fixed here)
Api\v1\ServiceQuoteController::bestQuote()returnsnullfor an empty collection and is passed straight intoserviceQuoteResource(ServiceQuote $serviceQuote), which is non-nullable — so requestingsingle=1when no service rate is servicable for the given waypoints returns HTTP 500 instead of a meaningful "no quotes available" response. The same shape appears at two entry points in that file. Details and a suggested guard are in this PR comment. Left unfixed deliberately: it is a behavior change that does not belong in a coverage PR.Notes